package com.sx.pipeline.ui.setting.feedback

import android.text.TextUtils
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.ToastUtils
import com.sx.pipeline.BR
import com.sx.pipeline.R
import com.sx.pipeline.app.base.CYDataBindingBaseActivity
import com.sx.pipeline.arouth.RoutePath
import com.sx.pipeline.databinding.ActFeedbackBinding
import com.sx.pipeline.utils.AndroidUtil


/**
 * @Author: YY
 * @Date: 2022/4/5
 * @Description: 意见反馈
 */
@Route(path = RoutePath.Setting.FEEDBACK)
class FeedbackActivity :
    CYDataBindingBaseActivity<ActFeedbackBinding, FeedbackVM>(R.layout.act_feedback),
    View.OnClickListener {


    override fun initData() {
        mBinding.setVariable(BR.onClick, this)
        mBinding.titleBar.leftView.setOnClickListener {
            finish()
        }
        //客服电话
        mBinding.tvPhone.text = "客服电话：" + mViewModel.mModel.getUserData()?.cusPhone
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.tv_phone -> {
                if (!TextUtils.isEmpty(mViewModel.mModel.getUserData()?.cusPhone)) {
                    mViewModel.mModel.getUserData()?.cusPhone?.let {
                        AndroidUtil.toCallPhone(
                            it,
                            this
                        )
                    }
                }
            }
            R.id.tv_submit -> {
                if (TextUtils.isEmpty(mBinding.etInput.text.toString())) {
                    ToastUtils.showShort("请填写您的反馈内容")
                    return
                }
                mViewModel.addFeedback(mBinding.etInput.text.toString())
            }
        }
    }

}